/**
 * 请求用户文章
 */

const mdModel = require('../models/mdModel')

function getMd(body) {
  return new Promise((resolve, reject) => {
    mdModel.findOne({ user_id: body.user_id }, (err, suc) => {
      if (err) {
        reject(err)
      } else {
        let obj = {
          user_name: body.user_name,
          user_id: body.user_id
        }
        if (!suc) {
          obj.user_md = []
        } else {
          obj.user_md = suc.user_md
        }
        resolve(obj)
      }
    })
  })
}

module.exports = {
  getMd
}